package com.woniu.his.dms.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.woniu.his.dms.client.CaseModelClient;
import com.woniu.his.dms.client.param.AddOrUpdateCaseModelClientParam;
import com.woniu.his.dms.client.result.CaseModelResult;
import com.woniu.his.dms.service.CaseModelService;
import com.woniu.his.dms.service.dto.CaseModelDto;
import com.woniu.his.dms.service.param.AddCaseModelCatalogParam;
import com.woniu.his.dms.service.param.AddOrUpdateCaseModelParam;
import com.woniu.his.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import java.util.List;

/**
 * @version: java version 1.8
 * @Author: ZJH
 * @description:
 * @date: 2022-11-29 21:00
 */
@RestController
@RequestMapping("dms")
@Slf4j
public class CaseModelApiImpl implements CaseModelClient {

    @Resource
    private CaseModelService caseModelService;

    @Override
    public Result<Boolean> addOrUpdateCaseModel(AddOrUpdateCaseModelClientParam param) {
        log.info("新增病历模板参数：{}",param);
        AddOrUpdateCaseModelParam catalogParam = BeanUtil.copyProperties(param, AddOrUpdateCaseModelParam.class);
        Boolean bool = caseModelService.addOrUpdateCaseModel(catalogParam);
        return Result.getInstance(Boolean.class).setData(bool);
    }

    @Override
    public Result<CaseModelResult> queryCaseModelById(Long id) {
        log.info("根据id查询病历模板参数：{}",id);
        CaseModelDto caseModelDto = caseModelService.queryCaseModelById(id);
        CaseModelResult caseModelResult = BeanUtil.copyProperties(caseModelDto, CaseModelResult.class);
        return Result.getInstance(CaseModelResult.class).setData(caseModelResult);
    }

    @Override
    public Result<Boolean> deleteCaseModelByIds(List<Long> ids) {
        log.info("根据ids删除病历模板：{}",ids);
        Boolean bool = caseModelService.deleteCaseModelByIds(ids);
        return Result.getInstance(Boolean.class).setData(bool);
    }
}
